/**
 * Created by WT-SUN on 2017/5/22.
 */

$(function () {
    queryYearthList("year");
    var monthArr=[];
    for(var i =1;i<13;i++){
        var idv="0"+i;
        var y = {id:idv,text:i+"月"};
        monthArr.push(y);
    }
    $('#month').combobox(
        {
            data:monthArr,
            prompt:'请选择',
            valueField:'id',
            textField:'text',
            editable: false
        }
    );
});
function queryYearthList(id){
    var date = new Date();
    var year = date.getFullYear();
    var yearthData = new Array();
    //yearthData.push({id:"",text:"请选择"});
    for(var i =0;i<6;i++){
        var y = {id:year-i,text:(year-i)+'年'};
        yearthData.push(y);
    }
    $('#'+id).combobox(
        {
            data:yearthData,
            prompt:'请选择',
            valueField:'id',
            textField:'text',
            editable: false
        }
    );
}
function clearForm() {
    $('#rForm').form('reset');
}
/**
 * 提交表单
 */
function submitForm() {
    $('#rForm').form('submit', {
        url: ROOT_PATH + '/threeSimultaneities/report/insertSelective.shtml',
        onSubmit: function (param) {
            if (!$(this).form('validate')) {
                layer.alert('请正确填写信息', {icon: 5});
            }
            return $(this).form('validate');
        },
        success: function (result) {
            result = $.parseJSON(result);
            if (result.success) {
                layer.msg('保存成功', {
                    icon: 1,
                    time: 1000
                }, function () {
                    WindowManager.closeLayer({
                        returnValue: true
                    });
                });
            }
            else {
                layer.msg('保存失败', {
                    icon: 2,
                    time: 1000
                });
            }
        }
    });
}

